package com.baizhi.service.impl;

import com.baizhi.dao.BannerDao;
import com.baizhi.entity.Banner;
import com.baizhi.service.BannerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class BannerServiceImpl implements BannerService {
    @Resource
    private BannerDao bannerDao;
    @Override
    @Transactional(readOnly = true)
    public PageInfo<Banner> selectAll(Integer page, Integer limit, String bannerOldName) {
        PageHelper.startPage(page,limit);
        PageInfo<Banner> pageInfo = new PageInfo<>(bannerDao.selectAll(bannerOldName));

        return pageInfo;
    }

    @Override
    @Transactional(readOnly = true)
    public Banner selectOne(Integer id) {
        Banner banner = bannerDao.selectOne(id);
        return banner;
    }

    @Override
    public void insert(Banner banner) {
        bannerDao.insert(banner);
    }

    @Override
    public void update(Banner banner) {
        bannerDao.update(banner);
    }
    @Override
    public void falseDeletes(Integer id) {
        bannerDao.falseDeletes(id);
    }
}
